package com.yitong.main.controller;

import com.yitong.main.service.ToolsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.ServletException;

@RestController
@RequestMapping("_")
public class ToolsController {

    @Autowired
    ToolsService service;

    @GetMapping( "beans/{pid}" )
    public Object getBeans(@PathVariable String pid) {

        return service.getBeans(pid);
    }


    /**
     * 启动项目
     * @return
     * @throws ServletException
     */
    @PostMapping( "/start" )
    public String start(@RequestBody String pid) {
        // 加载IService下所有的服务
        service.start(pid);
        return "ok";
    }


    @PostMapping( "/stop" )
    public String stop(@RequestBody String pid) throws ServletException {
        // 加载IService下所有的服务
        service.stop(pid);
        return "ok";
    }

}
